﻿using System;
using ProtoBuf;

namespace TlvLib.Packets
{
    [ProtoContract]
    public class ImageData
    {
        [ProtoMember(1)]
        public DateTime CaptureTime;
        [ProtoMember(2)]
        public byte[] ImageBuffer;
    }

    [ProtoContract]
    public class Rect
    {
        [ProtoMember(1)]
        public int x;
        [ProtoMember(2)]
        public int y;
        [ProtoMember(3)]
        public int w;
        [ProtoMember(4)]
        public int h;

        public Rect()
        {

        }

        public Rect(int x, int y, int w, int h)
        {
            this.x = x;
            this.y = y;
            this.w = w;
            this.h = h;
        }
    }

    [ProtoContract]
    public class VideoData
    {
        [ProtoMember(1)]
        public DateTime Begin;
        [ProtoMember(2)]
        public DateTime End;
        [ProtoMember(3)]
        public string Format; //视频文件格式
        [ProtoMember(4)]
        public byte[] Data;

    }

    [ProtoBuf.ProtoContract]
    public class LicensePlateInfo
    {
        [ProtoBuf.ProtoMember(1)]
        public string MonitorId { get; set; }

        [ProtoBuf.ProtoMember(2)]
        public int CameraNo { get; set; }

        [ProtoBuf.ProtoMember(3)]
        public int RoadNo { get; set; }

        [ProtoBuf.ProtoMember(4)]
        public int DetectMethod { get; set; } //0:视频，1：线圈

        [ProtoBuf.ProtoMember(5)]
        public int Speed { get; set; }

        [ProtoBuf.ProtoMember(6)]
        public int SpeedLimit { get; set; }

        [ProtoBuf.ProtoMember(7)]
        public string Direction { get; set; }

        [ProtoBuf.ProtoMember(8)]
        public int CarType { get; set; } //车型

        [ProtoBuf.ProtoMember(9)]
        public string PlateNo { get; set; }

        [ProtoBuf.ProtoMember(10)]
        public int PlateColor { get; set; }

        [ProtoBuf.ProtoMember(11)]
        public Rect PlatePosition { get; set; }

        [ProtoBuf.ProtoMember(12)]
        public int Confidence { get; set; }

        [ProtoBuf.ProtoMember(13)]
        public bool IsViolation { get; set; } //是否违章

        [ProtoBuf.ProtoMember(14)]
        public string ViolationType { get; set; } //违章类型

        [ProtoBuf.ProtoMember(15)]
        public DateTime RedLightBeginTime { get; set; } //红灯开始时间

        [ProtoBuf.ProtoMember(16)]
        public string PacketId { get; set; }

        [ProtoBuf.ProtoMember(17)]
        public VideoData[] Videos;

        [ProtoBuf.ProtoMember(18)]
        public ImageData[] Images { get; set; }

        [ProtoMember(19)]
        public DateTime TimeStamp { get; set; }

        public LicensePlateInfo()
        {
            MonitorId = string.Empty;
            Direction = string.Empty;
            PlateNo = string.Empty;
            ViolationType = string.Empty;
            PacketId = string.Empty;

            Images = new ImageData[0];
            Videos = new VideoData[0];
        }
    }
}
